<%@page contentType="text/html; charset=utf-8" language="java" %>
<%@page import="biz.UserBiz" %>
<%@page import="bean.User" %>
<%
if(session.getAttribute("uid") == null){
	out.print("<script>alert('请先登录！');history.back();</script>");
	response.sendRedirect("login.jsp");
}
User user = UserBiz.getUserByUid(Integer.parseInt(session.getAttribute("uid").toString()));
String action = request.getParameter("action");
if((action != null) && action.equals("up")){
	boolean flag = UserBiz.updatePassword(user.getUid(),request.getParameter("oldpass"),request.getParameter("newpass"));
	if(flag){
		session.setAttribute("uid",null);
		out.print("<script>alert('更新成功，即将转向您的页面！');history.back();</script>");
		response.sendRedirect("login.jsp");
	}else{
		out.print("<script>alert('系统错误！请稍候再试');history.back();</script>");
	}
}
%>
<html>
	<head>
	<link href="css.css" rel="stylesheet" type="text/css">
		<title>更新iWiki密码</title>
	</head>
	<body>
	<jsp:include page="/head.jsp"/>
		<center><fieldset>
			<p class="f_title">更改密码</p>
			<div class="disc">修改密码时，您需要提交从前的密码。</div>
			<form method="post" action="updatepass.jsp?action=up">
				<ol>
				<li><label for="uname">原始密码：</label><span><input type="password" name="oldpass" class="input" style="width:180px;"></span></li>
				<li><label for="email">重设密码：</label><span><input type="password" name="newpass" class="input" style="width:180px;"></span></li>
				</ol>
				<input type="submit" value="更改密码" style="width:80px" class="button"/>
				<input type="reset" value="重填" style="width:60px" class="button"/>	
			</form>
		</fieldset></center>
	<jsp:include page="/copyright.html"/>
	</body>
</html>